package com.zq.widget.inverted.game.role.level;

/**
 * Created by zhangqiang on 2018/4/4.
 */
public class LevelProxy implements Level{

    private int level;
    private final int maxLevel;

    public LevelProxy(int maxLevel) {
        this.maxLevel = maxLevel;
    }

    @Override
    public void levelUp(int deltaLevel) {

        if(deltaLevel <= 0){
            return;
        }
        level = Math.min(level + deltaLevel,maxLevel);
    }

    @Override
    public void levelDown(int deltaLevel) {
        if(deltaLevel <= 0){
            return;
        }
        level = Math.max(0,level - deltaLevel);
    }

    @Override
    public int level() {
        return level;
    }

    @Override
    public int maxLevel() {
        return maxLevel;
    }

    @Override
    public float levelFactor() {
        return (float)level/maxLevel;
    }
}
